package com.example.loginproject.view.fragments

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.activityViewModels
import com.example.loginproject.databinding.FragmentChooseUserBottomSheetBinding
import com.example.loginproject.view.viewModels.SharedViewModel
import com.google.android.material.bottomsheet.BottomSheetDialogFragment

class ChooseUserBottomSheetFragment :BottomSheetDialogFragment() {
    private lateinit var binding: FragmentChooseUserBottomSheetBinding
    private val viewModel: SharedViewModel by activityViewModels()

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        binding = FragmentChooseUserBottomSheetBinding.inflate(inflater, container, false)
        return binding.root
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)

        binding.hxl.setOnClickListener {
            viewModel.loadUserInfo(binding.hxl.text.toString())
           dismiss()
        }

        binding.zs.setOnClickListener {
            viewModel.loadUserInfo(binding.zs.text.toString())
            dismiss()
        }

        binding.dismiss.setOnClickListener {
            dismiss()
        }
    }
}

